﻿using System.Web;
using ASPItalia.ModelVirtualCasting.EntityFramework.Wrappers;

namespace ASPItalia.ModelVirtualCasting.EntityFramework
{
    public class WebContextContainer : IContextContainer
    {
        private const string CONTEXT_KEY = "EFObjectContext";

        public WebContextContainer()
        {
        }

        public ContextWrapper Current
        {
            get { return (ContextWrapper)HttpContext.Current.Items[CONTEXT_KEY]; }
        }

        public void Clear()
        {
            HttpContext.Current.Items[CONTEXT_KEY] = new ContextWrapper(new ModelVirtualCastingEntities(Configuration.ConnectionString));
        }
    }
}